#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
配置设置脚本
用于快速配置Milvus连接信息
"""

import os

from config import MILVUS_HOST, MILVUS_PORT, MILVUS_USERNAME, MILVUS_PASSWORD, MILVUS_TOKEN, TARGET_DIRECTORY, \
    MAX_FILES, COLLECTION_NAME


def setup_config():
    """设置配置文件"""
    print("=" * 50)
    print("Milvus 文件搜索系统配置")
    print("=" * 50)
    
    # 检查是否已存在配置文件
    config_file = "../config.py"
    # if os.path.exists(config_file):
    #     overwrite = input(f"配置文件 {config_file} 已存在，是否覆盖？(y/n): ").lower()
    #     if overwrite != 'y':
    #         print("配置取消")
    #         return
    
    print("\n请输入Milvus连接信息:")
    
    # 收集配置信息
    milvus_host = MILVUS_HOST

    # 清理host参数，移除协议前缀
    if milvus_host.startswith("http://"):
        milvus_host = milvus_host[7:]
    elif milvus_host.startswith("https://"):
        milvus_host = milvus_host[8:]
    
    milvus_port = MILVUS_PORT

    username = MILVUS_USERNAME
    password = MILVUS_PASSWORD
    token = MILVUS_TOKEN

    # 其他配置
    target_directory = TARGET_DIRECTORY

    max_files = MAX_FILES

    collection_name = COLLECTION_NAME


if __name__ == "__main__":
    setup_config()